#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstring>
#define endl "\n"
using namespace std;
int main()
{
	int n, a[105] = { 0 }, b[2][105] = { 0 },Max=0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		b[0][i] = 1;
		b[1][i] = 1;
	}
	for (int i = 2; i <= n; i++)
	{
		for (int j = 1; j <= i; j++)
		{
			if (a[i] > a[j] && b[0][i] < b[0][j] + 1)
				b[0][i] = b[0][j] + 1;
		}
	}
	for (int i = n-1; i >= 1; i--)
	{
		for (int j =n ; j >= i; j--)
		{
			if (a[i] > a[j] && b[1][i] < b[1][j] + 1)
				b[1][i] = b[1][j] + 1;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		Max = max(b[0][i] + b[1][i] - 1, Max);
	}
	printf("%d", n-Max);
	return 0;
}